package com.android.kmlmrg.listener;


import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.android.kmlmrg.model.User;
import com.android.kmlmrg.model.Users;
import com.android.kmlmrg.services.ServiceController;
import com.android.kmlmrg.views.FormAuthentication;
import com.android.kmlmrg.views.ViewContact;

public class SearchItemListener implements OnItemClickListener{

	/** LOG **/
	private static final String LOG_TAG = SearchItemListener.class.getName();

	private Activity activity;
	private ServiceController serviceController;
	public SearchItemListener( Activity pActivity ){
		activity = pActivity;
		serviceController = ServiceController.getInstance();
	}
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		Log.i(LOG_TAG, "START onItemClick "  );
	    Users users = serviceController.getUsers();
		User user = users.getList().get(position);
		Application vApplication = serviceController.getApplication();
		Log.i(LOG_TAG, "User Serialization" + user.getNom()  );
		Intent intent = new Intent( vApplication,ViewContact.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
		intent.putExtra("viewContact",user);
		vApplication.startActivity(intent);

	
		Log.i(LOG_TAG, "END onItemClick "  );
	}


}
